package com.xiweicheng.test.springboot.jpa;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Slf4j
@Service
public class UserServiceImpl implements  UserService {

    @Autowired
    UserRepository userRepository;

//    @Transactional
    @Override
    public void test() {
        User user = userRepository.findOne(3L);
        log.info("{}", user);
        user = userRepository.findOne(3L); // 加了 @Transactional 不会再次发起真正的sql查询
        log.info("{}", user);
    }
}
